package com.wee.aircoach_user;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.animation.AccelerateInterpolator;

import com.bigtotoro.widgets.FixedSpeedScroller;
import com.wee.fragment.FragRegister2;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

public class RegisterActivity extends FragmentActivity {

    private List<Fragment> fragmentList = new ArrayList<>();
    public ViewPager viewPager;

    public String purpose;
    public String pathUrl;
    public String code;
    public String email, phone, verifyCode, pwd, name, address, idCard;
    public List<String> idCardPaths;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register2);

        viewPager = (ViewPager)findViewById(R.id.viewpager);
       // Fragment fragment1 = new FragRegister0();
        Fragment fragment3 = new FragRegister2();
        fragmentList = new ArrayList<Fragment>();
      //  fragmentList.add(fragment1);

        fragmentList.add(fragment3);
        viewPager.setAdapter(new MyViewPagerAdapter(getSupportFragmentManager()));
        viewPager.setOnPageChangeListener(new MyOnPageChangeListener());


        try {
            Field mScroller;
            mScroller = ViewPager.class.getDeclaredField("mScroller");
            mScroller.setAccessible(true);
            FixedSpeedScroller scroller = new FixedSpeedScroller(viewPager.getContext(), new AccelerateInterpolator());
            mScroller.set(viewPager, scroller);
        } catch (NoSuchFieldException e) {
        } catch (IllegalArgumentException e) {
        } catch (IllegalAccessException e) {
        }
    }

    public class MyViewPagerAdapter extends FragmentPagerAdapter {
        public MyViewPagerAdapter(FragmentManager fm) {
            super(fm);
        }
        @Override
        public Fragment getItem(int arg0) {
            return fragmentList.get(arg0);
        }
        @Override
        public int getCount() {
            return fragmentList.size();
        }
    }

    public class MyOnPageChangeListener implements ViewPager.OnPageChangeListener {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    }
}
